﻿<sap:ActivityDesigner x:Class="Vision.Core.ActivityComponents.Conversion.FromToDesigner"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities"
    xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
    xmlns:sapc="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation"
    xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"
    Collapsible="True" ExpandState="True" Icon="{DynamicResource DesignerIcon}">
    <sap:ActivityDesigner.Resources>
        <DrawingBrush x:Key="DesignerIcon" Stretch="Uniform">
            <DrawingBrush.Drawing>
                <DrawingGroup>
                    <DrawingGroup.Children>
                        <GeometryDrawing Geometry="F1 M 90.5,73.25C 129.436,73.25 161,104.814 161,143.75C 161,182.686 129.436,214.25 90.5,214.25C 51.5639,214.25 20,182.686 20,143.75C 20,104.814 51.5639,73.25 90.5,73.25 Z ">
                            <GeometryDrawing.Brush>
                                <LinearGradientBrush StartPoint="-0.00354609,0.5" EndPoint="1.00355,0.5">
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStop Color="#FF1D43B1" Offset="0"/>
                                        <GradientStop Color="#FF1D43B1" Offset="0.795349"/>
                                        <GradientStop Color="#FF587EEB" Offset="1"/>
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </GeometryDrawing.Brush>
                        </GeometryDrawing>
                        <DrawingGroup ClipGeometry="F1 M 90.5,73.25C 129.436,73.25 161,104.814 161,143.75C 161,182.686 129.436,214.25 90.5,214.25C 51.5639,214.25 20,182.686 20,143.75C 20,104.814 51.5639,73.25 90.5,73.25 Z ">
                            <DrawingGroup.Children>
                                <GeometryDrawing Brush="#FFFFFFFF" Geometry="F1 M 90.5,98.75C 115.629,98.75 136,119.121 136,144.25C 136,169.379 115.629,189.75 90.5,189.75C 65.371,189.75 45,169.379 45,144.25C 45,119.121 65.371,98.75 90.5,98.75 Z ">
                                    <GeometryDrawing.Pen>
                                        <Pen LineJoin="Round" Brush="#FF1D43B1"/>
                                    </GeometryDrawing.Pen>
                                </GeometryDrawing>
                            </DrawingGroup.Children>
                        </DrawingGroup>
                        <GeometryDrawing Geometry="F1 M 90.5,73.25C 129.436,73.25 161,104.814 161,143.75C 161,182.686 129.436,214.25 90.5,214.25C 51.5639,214.25 20,182.686 20,143.75C 20,104.814 51.5639,73.25 90.5,73.25 Z ">
                            <GeometryDrawing.Pen>
                                <Pen LineJoin="Round" Brush="#FF153389"/>
                            </GeometryDrawing.Pen>
                        </GeometryDrawing>
                        <GeometryDrawing Geometry="F1 M 221.537,59.3614L 158.073,212.101L 285,212.101L 221.537,59.3614 Z ">
                            <GeometryDrawing.Brush>
                                <LinearGradientBrush StartPoint="-0.00393928,0.5" EndPoint="1.00394,0.5">
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStop Color="#FFB11F1F" Offset="0"/>
                                        <GradientStop Color="#FFB11F1F" Offset="0.795349"/>
                                        <GradientStop Color="#FFD84848" Offset="1"/>
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </GeometryDrawing.Brush>
                        </GeometryDrawing>
                        <DrawingGroup ClipGeometry="F1 M 221.537,59.3614L 158.073,212.101L 285,212.101L 221.537,59.3614 Z ">
                            <DrawingGroup.Children>
                                <GeometryDrawing Brush="#FFFFFFFF" Geometry="F1 M 221.073,109.143L 188.407,191.358L 253.74,191.358L 221.073,109.143 Z ">
                                    <GeometryDrawing.Pen>
                                        <Pen LineJoin="Round" Brush="#FFB11F1F"/>
                                    </GeometryDrawing.Pen>
                                </GeometryDrawing>
                            </DrawingGroup.Children>
                        </DrawingGroup>
                        <GeometryDrawing Geometry="F1 M 221.537,59.3614L 158.073,212.101L 285,212.101L 221.537,59.3614 Z ">
                            <GeometryDrawing.Pen>
                                <Pen LineJoin="Round" Brush="#FF831616"/>
                            </GeometryDrawing.Pen>
                        </GeometryDrawing>
                        <GeometryDrawing Brush="#FF000000" Geometry="M 220.936,142.755L 176.218,107.655L 176.218,177.855L 220.936,142.755 Z M 85.9424,130.899L 176.165,131.256L 176.165,152.129L 85.9424,151.485L 85.9424,130.899 Z ">
                            <GeometryDrawing.Pen>
                                <Pen LineJoin="Round" Brush="#FF000000"/>
                            </GeometryDrawing.Pen>
                        </GeometryDrawing>
                    </DrawingGroup.Children>
                </DrawingGroup>
            </DrawingBrush.Drawing>
        </DrawingBrush>
        
        <sapc:ArgumentToExpressionConverter x:Uid="sadv:ArgumentToExpressionConverter_1" x:Key="argumentToExpressionConverter" />

        <DataTemplate x:Key="ExpandedActivityDesignerTemplate">
            <StackPanel>
                <!-- Inputs Header -->
                <TextBlock Text="Input(s):" FontWeight="Bold" Foreground="Navy" Margin="0,0,0,3" />
                
                <Grid Margin="0,5,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="85" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>

                    <!-- ModelItem.Source -->
                    <TextBlock Grid.Row="1" Grid.Column="0" Text="Source:" VerticalAlignment="Top" />
                    <sapv:ExpressionTextBox Grid.Row="1" Grid.Column="1"
                        MaxLines="1" Margin="7,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Top"
                        Expression="{Binding Path=ModelItem.Source, Mode=TwoWay, Converter={StaticResource argumentToExpressionConverter}, ConverterParameter=In}"
                        ExpressionType="{Binding Path=ModelItem.Source.ArgumentType}"
                        OwnerActivity="{Binding Path=ModelItem, Mode=OneWay}" />
                </Grid>

                <!-- Inputs Header -->
                <TextBlock Text="Output(s):" FontWeight="Bold" Foreground="Navy" Margin="0,0,0,3" />

                <Grid Margin="0,5,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="85" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>

                    <!-- ModelItem.Source -->
                    <TextBlock Grid.Row="1" Grid.Column="0" Text="Output:" VerticalAlignment="Top" />
                    <sapv:ExpressionTextBox Grid.Row="1" Grid.Column="1"
                        MaxLines="1" Margin="7,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Top"
                        Expression="{Binding Path=ModelItem.Output, Mode=TwoWay, Converter={StaticResource argumentToExpressionConverter}, ConverterParameter=Out}"
                        ExpressionType="{Binding Path=ModelItem.Output.ArgumentType}"
                        OwnerActivity="{Binding Path=ModelItem, Mode=OneWay}"
                        UseLocationExpression="True"/>
                </Grid>

                <Border BorderThickness="0,0,0,3" Margin="0,5">
                    <Border.BorderBrush>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="DarkGray" Offset="0" />
                            <GradientStop Color="White" Offset="1" />
                        </LinearGradientBrush>
                    </Border.BorderBrush>
                </Border>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="85" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Row="0" x:Uid="TextBlock_5" Text="Body Argument:" VerticalAlignment="Top" Foreground="Gray" />
                    <TextBox Grid.Row="0" Grid.Column="1" x:Uid="TextBox_1" Text="{Binding Path=ModelItem.Body.Argument.Name, Mode=TwoWay}" Margin="7,0,0,0" Foreground="Gray" />
                </Grid>
                <!-- Body -->
                <sap:WorkflowItemPresenter x:Uid="sad:WorkflowItemPresenter_1" AutomationProperties.AutomationId="Activity" IsDefaultContainer="True" HintText="Drop activity here" Item="{Binding Path=ModelItem.Body.Handler, Mode=TwoWay}" AllowedItemType="{x:Type sa:Activity}" MinWidth="100" MinHeight="100" Margin="0,7,0,0"/>

            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Key="CollapsedActivityDesignerTemplate">
            <Label Padding="0,0,0,0" FontStyle="Italic" Foreground="{x:Static SystemColors.GrayTextBrush}" HorizontalAlignment="Center" VerticalAlignment="Center">Double-click to view</Label>
        </DataTemplate>
        <Style x:Uid="Style_1" x:Key="DesignerStyle" TargetType="{x:Type ContentPresenter}">
            <Setter x:Uid="Setter_1" Property="ContentTemplate" Value="{DynamicResource ExpandedActivityDesignerTemplate}" />
            <Style.Triggers>
                <DataTrigger x:Uid="DataTrigger_1" Binding="{Binding Path=ShowExpanded}" Value="false">
                    <Setter x:Uid="Setter_2" Property="ContentTemplate" Value="{DynamicResource CollapsedActivityDesignerTemplate}" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </sap:ActivityDesigner.Resources>

    <ContentPresenter x:Uid="ContentPresenter_1" x:Name="ContentPresenter_1" Style="{DynamicResource DesignerStyle}" Content="{Binding}" />
</sap:ActivityDesigner>
